package com.mpsc.api.unit;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class Test2 {

    public static void main(String[] args) {
        String[] strs = {"a", "b", "c"};
        test(3, strs);
    }

    //需要用递归算法
    private static void test1(int size, String[] strs) {
        for (int i = 0; i < size; i++){
            
        }

    }


    private static void test(int size, String[] strs) {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            StringBuffer buffer = new StringBuffer();
            buffer.append(strs[i]);
            for (int j = i + 1; j < size; j++) {
                buffer.append(strs[j]);
            }
            for (int z = 0; z < i; z++) {
                buffer.append(strs[z]);
            }
            list.add(buffer.toString());
        }

        Stream<String> sorted = list.stream().sorted();
        sorted.forEach(s -> System.out.println(s));
    }
}
